﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ToolStripButtonAdapter.cs" company="">
//   
// </copyright>
// <summary>
//   The tool strip button adapter.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Libium.Adapters
{
    using System;
    using System.Windows.Forms;

    using Libium.Views;

    /// <summary>
    /// The tool strip button adapter.
    /// </summary>
    public class ToolStripButtonAdapter : ToolStripItemAdapter<ToolStripButton>, ICommandView
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="ToolStripButtonAdapter"/> class.
        /// </summary>
        /// <param name="button">
        /// The button.
        /// </param>
        public ToolStripButtonAdapter(ToolStripButton button)
            : base(button)
        {
            Control.Click += OnClick;
        }

        #endregion

        #region Public Events

        /// <summary>
        /// The execute.
        /// </summary>
        public event Action<ICommandView> Execute;

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        public string Name
        {
            get
            {
                return string.Empty;
            }

            set
            {
            }
        }

        /// <summary>
        /// Gets or sets the text.
        /// </summary>
        public string Text
        {
            get
            {
                return Control.Text;
            }

            set
            {
                Control.Text = value;
            }
        }

        /// <summary>
        /// Gets or sets the tooltip.
        /// </summary>
        public string Tooltip
        {
            get
            {
                return Control.ToolTipText;
            }

            set
            {
                Control.ToolTipText = value;
            }
        }

        #endregion

        #region Methods

        /// <summary>
        /// The on click.
        /// </summary>
        /// <param name="source">
        /// The source.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected virtual void OnClick(object source, EventArgs e)
        {
            if (Execute != null)
            {
                Execute(this);
            }
        }

        #endregion
    }
}